@extends('layouts.console_header')

@section('title', '地推商家列表')

@section('resources')
    @parent
    <link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/jquery.dataTables.min.css?v={{env('CSS_VERSION')}}">
    <style>
    	.shop_lists{width: 1200px;margin: 0 auto;padding-bottom: 30px;}
    	.shop_lists .account_title{margin: 0 auto;height: 48px;line-height: 48px;border-bottom: 2px solid #9955c6;padding-left: 10px;}
		.back_btn{position: relative;width: 140px;}
		.back_btn ul{border: 1px solid #333;position: absolute;top: 30px;left: 0;color: #000;z-index: 10;width: 140px;text-align: center;background-color: #fff;display: none;}
		.back_btn ul li{cursor: pointer;}
		.shop_newadd{position: fixed;top: 200px;left: 50%;width: 600px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
		.shop_newaddspec{position: fixed;top: 200px;left: 50%;width: 600px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
		.shop_eweima{position: fixed;top: 50%;left: 50%;width: 600px;height: 415px;margin-top: -200px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
		.shop_title{height: 50px;line-height: 50px;border-bottom: 1px solid #333;}
		.shop_title p{width: 550px;text-align: center;}
		.shop_title img{width: 30px;margin: 10px;}
		.shop_lists_content{padding: 0 20px;}
		.shop_lists_content li{margin: 10px 0;}
		.shop_lists_content input[type='text']{width: 350px;height: 30px;border: 1px solid #ccc;padding-left: 10px;}
		.shop_lists_content .shop_lists_detailsbtn{width: 120px;height: 30px;border: 1px solid #ccc;background-color: #9955c6;color: #fff;border-radius: 10px;}
		.shop_lists_content select{width: 120px;height: 30px;border: 1px solid #ccc;}
		.shop_lists_detailsinfo{display: none;}
		.shop_lists_detailsinfo p{overflow: hidden;}
		.shop_lists_detailsinfo span{float: left;margin-left: 20px;}
		.shop_lists_detailsinfo .shop_lists_infotitle{width: 80px;margin-left: 80px;}
		.shop_newadd .shop_newadd_btn{width: 350px;height: 40px;margin: 20px 125px;background-color: #9955c6;color: #fff;border-radius: 10px;}
		.shop_newaddspec .shop_newaddspec_btn{width: 350px;height: 40px;margin: 20px 125px;background-color: #9955c6;color: #fff;border-radius: 10px;}
    	.shop_eweima_content li{text-align: center;margin: 10px;}
    	.shop_eweima .shop_downloadewm{width: 350px;height: 40px;margin: 0 125px;background-color: #9955c6;color: #fff;border-radius: 10px;position: absolute;bottom: 20px;}
    	.shop_upgrade{position: fixed;top: 50%;left: 50%;width: 600px;height: 415px;margin-top: -200px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
    	.shop_upgrade .shop_upgrade_btn{width: 350px;height: 40px;margin: 0 125px;background-color: #9955c6;color: #fff;border-radius: 10px;position: absolute;bottom: 20px;}
    	.shop_down{position: fixed;top: 50%;left: 50%;width: 600px;height: 415px;margin-top: -200px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
    	.shop_down .shop_down_btn{width: 350px;height: 40px;margin: 0 125px;background-color: #9955c6;color: #fff;border-radius: 10px;position: absolute;bottom: 20px;}
        .shop_renew{position: fixed;top: 50%;left: 50%;width: 600px;height: 415px;margin-top: -200px;margin-left: -300px;background-color: #fff;border: 1px solid #333;display: none;z-index: 1001;}
        .shop_renew .shop_renew_btn{width: 350px;height: 40px;margin: 0 125px;background-color: #9955c6;color: #fff;border-radius: 10px;position: absolute;bottom: 20px;}
    </style>
@endsection

@section('content')
<section class="shop_lists">
    <div style="border-bottom: 2px solid #9955c6;height: 50px;">
        <p class="fz_14 account_title fl" style="border: none;"><span style="color: #7f7f7f;"><a href="/console/index">首页</a>>地推管理></span><span class="co_violet">地推商家列表</span></p>
        <div class="fr tc back_btn">
        	<p style="cursor: pointer;">+新增</p>
            <ul>
        		<li style="border-bottom: 1px solid #333;">合作商家普通地推</li>
        		<li>合作商家地推合伙人</li>
        	</ul>
        </div>
    </div>
    <table id="example" class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th style="width: 90px;">门店登录账号</th>
                <th>门店名称</th>
                <th>商务</th>
                <th>地推类型</th>
                <th>注册用户</th>
                <th>有效订单</th>
                <th>已提现金额(元)</th>
                <th>账户余额(元)</th>
                <th>状态</th>
                <th>创建时间</th>
                <th style="width: 280px;">操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>商家代码</th>
                <th>门店登录账号</th>
                <th>门店名称</th>
                <th>商务</th>
                <th>地推类型</th>
                <th>注册用户</th>
                <th>有效订单</th>
                <th>已提现金额(元)</th>
                <th>账户余额(元)</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </tfoot>
        <tbody>
        @foreach($lists as $list)
            <tr>
            @if(!isset($i))
            	<td>{{$i=1}}</td>
            @else
                <td>{{++$i}}</td>
            @endif
                <td>{{$list['code']}}</td>
                <td>{{$list['parentmobile']}}</td>
                <td>{{$list['shopname']}}</td>
                <td>{{$list['adminname']}}</td>
            @if($list['type'] == 'common')
                <td>普通地推</td>
            @elseif($list['type'] == 'partner')
                <td>地推合伙人</td>
            @else
                <td></td>
            @endif
                <td>{{$list['commonregisternum'] + $list['partnerregisternum']}}</td>
                <td>{{$list['validordernum']}}</td>
                <td>{{$list['withdrawalmoney']}}</td>
                <td>{{$list['balance']}}</td>
            @if($list['status'] == 1)
                <td>可用</td>
            @else
                <td>不可用</td>
            @endif
                <td>{{date('Y-m-d H:i:s', strtotime($list['created_at']))}}</td>
                <td>
                @if($list['qrcode'] != '')
                	<a style="margin-right: 10px;" class="co_violet download_eweima" href="#" onclick="show_qrcode('{{$list['qrcode']}}', '{{$list['shopname']}}', '{{$list['address']}}')">二维码</a>
                @endif
                	<a style="margin-right: 10px;" class="co_violet" href="/console/salesman/shop/get?cityid={{$cityid}}&shopid={{$list['shopid']}}">地推详情</a>
                    <a style="margin-right: 10px;" class="co_violet" href="/console/salesman/shop/withdrawal/lists?cityid={{$cityid}}&shopid={{$list['shopid']}}">结算详情</a>
                @if($list['status'] == 1)
                    @if($list['type'] == 'common')
                        <a style="margin-right: 10px;" class="co_violet" href="#" onclick="upgrade('{{$list['shopid']}}', '{{$list['shopname']}}', '{{$list['address']}}')">升级</a>
                    @endif
                	<a class="co_violet " href="#" onclick="termination('{{$list['shopid']}}', '{{$list['shopname']}}', '{{$list['address']}}', '{{$list['payfee']}}', '{{$list['contractmonth']}}', '{{$list['contractstarttime']}}', '{{$list['contractlasttime']}}','{{$list['withdrawalmoney']}}')">终止</a>
                @else
                    <a class="co_violet" href="#" onclick="renew('{{$list['shopid']}}', '{{$list['shopname']}}', '{{$list['address']}}')">恢复</a>
                @endif
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>

    <!---  普通地推  -->
    <form action="" method="" class="shop_newadd">
    	<div class="shop_title oh">
    		<p class="fl">新增合作商家的普通地推</p>
    		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    	</div>
    	<ul class="shop_lists_content">
    		<li class="co_gray56">普通地推：商家不需要缴纳1万元，仅参与下载app注册用户 5元／每个注册用户，不参与有效订单的地推。地推时限：1年</li>
    		<li class="shop_lists_details">
    			<span style="display: inline-block;width: 64px;text-align: right;">商家</span>
    			<input class="fz_14" type="text" name="shopcode" value="" placeholder="请输入商家代码">
    			<input class="shop_lists_detailsbtn inforbtn1 fz_16" type="button" name="" value="获取商家信息">
    		</li>
    		<li class="shop_lists_detailsinfo infor1 co_gray56" id="common_shop">
    		</li>
    	</ul>
    	<input class="shop_newadd_btn fz_18" type="button" name="" value="添加">
    </form>

    <!--- 商家合伙人地推  -->
    <form action="" method="" class="shop_newaddspec">
    	<div class="shop_title oh">
    		<p class="fl">新增合作商家的地推合伙人</p>
    		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    	</div>
    	<ul class="shop_lists_content">
    		<li class="fz_13 co_gray56">地推合伙人：地推收益由注册用户与地推订单组成。</li>
    		<li class="fz_13 co_gray56">注册用户：前1000名注册用户10元／个，1000名以后注册用户5元／个；地推订单：按订单实付金额的1%计为地推订单的收益。</li>
    		<li>
    			<span>缴纳金额</span>
    			<input style="width: 100px;" type="text" name="payfee" value="10000">
    			<span>元</span>
    		</li>
    		<li>
    			<span>地推时间</span>
    			<select name="contractmonth" id="">
    				<option value="36">36个月</option>
    				<option value="24">24个月</option>
    				<option value="12">12个月</option>
    				<option value="6">6个月</option>
    			</select>
    		</li>
            <li class="fz_13 co_gray56">
                <span style="font-size: 18px;color: #000;letter-spacing: 15px;">密码</span>
                <input class="newaddspec_password" style="border: 1px solid #CCC;width: 190px;height: 20px;border-radius: 5px;padding: 5px;" type="password" name="newaddpassword" value="">
            </li>
    		<li class="shop_lists_details">
    			<span style="display: inline-block;width: 64px;text-align: right;">商家</span>
    			<input class="fz_14" type="text" name="shopcode" value="" placeholder="请输入商家代码">
    			<input class="shop_lists_detailsbtn inforbtn2 fz_16" type="button" name="" value="获取商家信息">
    		</li>
    		<li class="shop_lists_detailsinfo infor2 fz_14 co_gray56" id="partner_shop">
    		</li>
    	</ul>
    	<input class="shop_newaddspec_btn fz_18" type="button" name="" value="添加">
    </form>

    <!-- 二维码  -->
    <form action="" method="" class="shop_eweima">
    	<div class="shop_title oh">
    		<p class="fl">地推二维码</p>
    		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    	</div>
    	<ul class="shop_eweima_content">
    		<li class="fz_13 co_gray56"><span>门店名称 ：</span><span class="eweimashopname"></span></li>
    		<li class="fz_13 co_gray56"><span>门店地址 ：</span><span class="eweimashopaddress"></span></li>
    		<li id="output"></li>
    	</ul>
    	<!-- <input class="shop_downloadewm fz_18" type="button" name="" value="下载二维码"> -->
    </form>

    <!-- 升级 -->
    <form action="" method="" class="shop_upgrade">
    	<div class="shop_title oh">
    		<p class="fl">升级地推商家</p>
    		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    	</div>
    	<ul class="shop_lists_content">
    		<li class="fz_13 co_gray56 ">普通地推升级为地推合伙人：商家缴纳1万元，下载app注册用户 10元／每个注册用户，1元／每笔有效订单。</li>
    		<li class="fz_13 co_gray56"><span class="upgrade_shopid"><input type="hidden" name="upgrade_shopid" value=""></span></li>
    		<li class="fz_13 co_gray56"><span>门店名称 ：</span><span class="upgrade_shopname"></span></li>
    		<li class="fz_13 co_gray56"><span>门店地址 ：</span><span class="upgrade_address"></span></li>
    		<li>
    			<span>缴纳金额</span>
    			<input style="width: 100px;" type="text" name="upgrade_payfee" value="">
    			<span>元</span>
    		</li>
    		<li>
    			<span>地推时间</span>
    			<select name="upgrade_contractmonth" id="">
    				<option value="36">36个月</option>
    				<option value="24">24个月</option>
    				<option value="12">12个月</option>
    				<option value="6">6个月</option>
    			</select>
    		</li>
            <li class="fz_13 co_gray56">
                <span style="font-size: 18px;color: #000;letter-spacing: 15px;">密码</span>
                <input class="upgrade_password" style="border: 1px solid #CCC;width: 190px;height: 20px;border-radius: 5px;padding: 5px;" type="password" name="upgradepassword" value="">
            </li>
    	</ul>
    	<input class="shop_upgrade_btn fz_18" type="button" name="submit_upgrade_shop" value="升级为地推合伙人">
    </form>

    <!--- 终止 -->
    <form action="" method="" class="shop_down">
    	<div class="shop_title oh">
    		<p class="fl">终止地推商家</p>
    		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    	</div>
    	<ul class="shop_lists_content">
    	    <li class="fz_13 co_gray56"><span class="terminate_shopid"><input type="hidden" name="terminate_shopid" value=""></span></li>
    		<li class="fz_13 co_gray56"><span>门店名称 ：</span><span class="terminate_shopname"></span></li>
    		<li class="fz_13 co_gray56"><span>门店地址 ：</span><span class="terminate_address"></span></li>
    		<li class="fz_13 co_gray56"><span>地推时间：</span><span class="terminate_contractmonth"></span></li>
    		<li class="fz_13 co_gray56"><span>地推创建日：</span><span class="terminate_starttime"></span></li>
    		<li class="fz_13 co_gray56"><span>地推到期日：</span><span class="terminate_lasttime"></span></li>
    		<li class="fz_13 co_gray56"><span>缴纳金额：</span><span class="terminate_payfee"></span></li>
    		<li class="fz_13 co_gray56"><span>已提现金额：</span><span class="terminate_withdrawal"></span></li>
    		{{--<li>--}}
    			{{--<select name="" id="">--}}
    				{{--<option value="">请选择终止方式</option>--}}
    				{{--<option value="">不退款</option>--}}
    				{{--<option value="">退款</option>--}}
    			{{--</select>--}}
    		{{--</li>--}}
    	</ul>
    	<input class="shop_down_btn fz_18" type="button" name="submit_terminate_shop" value="终止地推商家">
    </form>

    <!--- 恢复 -->
    <form action="" method="" class="shop_renew">
        	<div class="shop_title oh">
        		<p class="fl">地推恢复</p>
        		<img class="fr shop_close" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
        	</div>
        	<ul class="shop_lists_content">
        	    <li class="fz_13 co_gray56"><span class="renew_shopid"><input type="hidden" name="renew_shopid" value=""></span></li>
        		<li class="fz_13 co_gray56"><span>门店名称 ：</span><span class="renew_shopname"></span></li>
        		<li class="fz_13 co_gray56"><span>门店地址 ：</span><span class="renew_address"></span></li>
        		<li>
        		    <span>地推类型：</span>
        		    <span>
                        <select name="renew_type" id="">
                            <option value="common">普通地推</option>
                            <option value="partner">地推合伙人</option>
                        </select>
                    </span>
        		</li>
        		<li class="fz_13 co_gray56"><span>缴纳金额：</span><span class="renew_payfee"><input type="text" name="renew_payfee" value=""></span></li>
        		<li>
        		    <span>地推时间：</span>
        			<select name="renew_contractmonth" id="">
        				<option value="36">36个月</option>
        				<option value="24">24个月</option>
        				<option value="12">12个月</option>
        				<option value="6">6个月</option>
        			</select>
        		</li>
        	</ul>
        	<input class="shop_renew_btn fz_18" type="button" name="submit_renew_shop" value="恢复地推商家">
        </form>
</section>
@endsection

@section('scriptResources')
    @parent
    <script src="{{env('JS_DOMAIN')}}js/jquery.dataTables.min.js?v={{env('JS_VERSION')}}"></script>
    <script type="text/javascript" src="{{env('JS_DOMAIN')}}js/jquery.qrcode.min.js"></script>
    <script>
        var cityid = '{{$cityid}}';
        var weburl = '{{env('WEB_URL')}}';
        var power = '{{$editpermission}}';
        var addpermission = '{{$addpermission}}';
    	$(function(){
    		$(".back_btn p").on("click",function(){
                if(shopPower('shopSalesmanManagement:add') == 1){
                    $(".back_btn ul").show();
                }else {
                    public_prompt();
                }
    		})
            $(document).click(function(){
                $(".back_btn ul").hide();
            });
            $(".back_btn p").click(function(event){
                event.stopPropagation();
            });
            $(".back_btn ul li").eq(0).on('click',function(){  //新增合作商家的普通地推
                $(".shop_newadd").show();
                $(".public_prompt_mark").show();
                $(".public_prompt_mark").height($(window).height());
                $(".back_btn ul").hide();
            });
            $('.inforbtn1').on('click',function(){
                $('.infor1').show();
                var shopcode = $(".shop_newadd input[name='shopcode']").val();
                $.ajax({
                    url:'/console/salesman/shop/search',
                    type: 'get',
                    data:{
                        cityid:cityid,
                        shopcode:shopcode
                    },
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            var data = data.data;
                            var string = '<p><input type="hidden" name="shopid" value="'+data.shopid+'"></p>'+
                                '<p><span class="shop_lists_infotitle">门店名称</span><span>'+data.shopname+'</span></p>' +
                                '<p><span class="shop_lists_infotitle">门店地址</span><span>'+data.address+'</span></p>' +
                                '<p><span class="shop_lists_infotitle">收款人</span><span>'+data.cardholder+'</span></p>' +
                                '<p><span class="shop_lists_infotitle">收款帐号</span><span>'+data.bankname+'</span><span>'+data.bankcard+'</span></p>'+
                                '<p><span class="shop_lists_infotitle">开户行</span><span>'+data.bankprovince+data.bankcity+data.opencardbank+'</span></p>';
                            $("#common_shop").html(string);
                        } else {
                            alert(data.message);
                        }
                    }
                })
            });
            $(".shop_newadd_btn").on('click',function(){
                $(".shop_newadd_btn").attr({"disabled":"disabled"});
                var shopid=$(".infor1 input[name='shopid']").val();
                var type='common';
                var payfee=0.00;
                var contractmonth=0;
                $.ajax({
                    url:'/console/salesman/shop/add',
                    type: 'post',
                    data:{
                        cityid:cityid,
                        shopid:shopid,
                        type:type,
                        payfee:payfee,
                        contractmonth:contractmonth
                    },
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            alert(data.message);
                            //$(".shop_newadd").hide();
                            location.reload();
                        } else {
                            alert(data.message);
                            $(".shop_newadd_btn").removeAttr("disabled");
                        }
                    }
                })
            });
            $(".back_btn ul li").eq(1).on('click',function() {  //新增合作商家的地推合伙人
                $(".public_prompt_mark").show();
                $(".public_prompt_mark").height($(window).height());
                if (addpermission == '1') {   //TODO 权限划分
                    $(".shop_newaddspec").show();
                    $(".back_btn ul").hide();
                } else if (addpermission == 0) {
                    public_prompt();
                };
            });
            $('.inforbtn2').on('click', function () {
                $('.infor2').show();
                var shopcode = $(".shop_newaddspec input[name='shopcode']").val();
                $.ajax({
                    url: '/console/salesman/shop/search',
                    type: 'get',
                    data: {
                        cityid: cityid,
                        shopcode: shopcode
                    },
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 'success') {
                            var data = data.data;
                            var string = '<p><input type="hidden" name="shopid" value="' + data.shopid + '"></p>' +
                                '<p><span class="shop_lists_infotitle">门店名称</span><span>' + data.shopname + '</span></p>' +
                                '<p><span class="shop_lists_infotitle">门店地址</span><span>' + data.address + '</span></p>' +
                                '<p><span class="shop_lists_infotitle">收款人</span><span>' + data.cardholder + '</span></p>' +
                                '<p><span class="shop_lists_infotitle">收款帐号</span><span>' + data.bankname + '</span><span>' + data.bankcard + '</span></p>' +
                                '<p><span class="shop_lists_infotitle">开户行</span><span>' + data.bankprovince + data.bankcity + data.opencardbank + '</span></p>';
                            $("#partner_shop").html(string);
                        } else {
                            alert(data.message);
                        }
                    }
                })
            });
            $(".shop_newaddspec_btn").on('click', function () {
                $(".shop_newaddspec_btn").removeAttr("disabled");
                var shopid = $(".infor2 input[name='shopid']").val();
                var type = 'partner';
                var payfee = $("input[name='payfee']").val();
                var contractmonth = $("select[name='contractmonth']").val();
                var newaddpassword = $("input[name='newaddpassword']").val();
                if($(".newaddspec_password").val() == ''){
                    alert("请输入密码");return;
                }
                $.ajax({
                    url: '/console/salesman/shop/add',
                    type: 'post',
                    data: {
                        cityid: cityid,
                        shopid: shopid,
                        type: type,
                        payfee: payfee,
                        contractmonth: contractmonth,
                        newaddpassword:newaddpassword,
                    },
                    dataType: 'json',
                    success: function (data) {
                        if (data.status == 'success') {
                            alert(data.message);
                            //$(".shop_newaddspec").hide();
                            location.reload();
                            $(".shop_newaddspec_btn").attr({"disabled":"disabled"});
                        } else {
                            alert(data.message);
                            $(".shop_newaddspec_btn").removeAttr("disabled");
                        }
                    }
                })
            });
            $(".shop_close").on('click',function(){
                $(this).parent().parent().hide();
                $(".public_prompt_mark").hide();
                $("#common_shop").html("");
                $("#partner_shop").html("");
                $(".upgrade_password").val("");
                $(".newaddspec_password").val("");
                $("input[name='shopcode']").val("")
            });
    	})

        //二维码
    	function show_qrcode(qrcode, shopname, address) {
            $(".public_prompt_mark").show();
            $(".public_prompt_mark").height($(window).height());
    	    $('#output').html("");
            //var qrcodeurl = weburl + "mobile/salesman/gotodownApp?shopid=" + shopid + "&shopname=" + encodeURI(shopname);
            var qrcodeurl = weburl + "qrcode/shop/" + qrcode;
    	    $(".eweimashopname").text(shopname);
    	    $(".eweimashopaddress").text(address);
    	    $(".shop_eweima").show();
            $('#output').qrcode(qrcodeurl);
    	}
    	//升级
    	function upgrade(shopid, shopname, address) {
            if(shopPower('shopSalesmanManagement:edit') == 1){
                $(".public_prompt_mark").show();
                $(".public_prompt_mark").height($(window).height());
                $(".upgrade_shopid input[name='upgrade_shopid']").val(shopid);
                $(".upgrade_shopname").text(shopname);
                $(".upgrade_address").text(address);
                $(".shop_upgrade").show();
            }else {
                public_prompt();
            }
    	}
    	$("input[name='submit_upgrade_shop']").click(function() {
    	    $(".shop_upgrade_btn").attr({"disabled":"disabled"});
    	    var shopid=$("input[name='upgrade_shopid']").val();
    	    var payfee=$("input[name='upgrade_payfee']").val();
    	    var contractmonth=$("select[name='upgrade_contractmonth']").val();
            var upgradepassword = $("input[name='upgradepassword']").val();
    	    if(shopid == '') {
                alert("请选择商家");return;
            }
    	    if($(".upgrade_password").val() == '') {
                alert("请输入密码");return;
            }
            $.ajax({
                url:'/console/salesman/shop/upgrade',
                type: 'post',
                data:{
                    cityid:cityid,
                    shopid:shopid,
                    payfee:payfee,
                    contractmonth:contractmonth,
                    upgradepassword:upgradepassword,
                },
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        //$(".shop_upgrade").hide();
                        location.reload();
                    } else {
                        alert(data.message);
                        $(".shop_upgrade_btn").removeAttr("disabled");
                    }
                }
            })
    	});
    	//终止
    	function termination(shopid, shopname, address, payfee, contractmonth, contractstarttime, contractlasttime,withdrawal) {
            if(shopPower('shopSalesmanManagement:edit') == 1){
                $(".public_prompt_mark").show();
                $(".public_prompt_mark").height($(window).height());
                $(".terminate_shopid input[name='terminate_shopid']").val(shopid);
                $(".terminate_shopname").text(shopname);
                $(".terminate_address").text(address);
                $(".terminate_contractmonth").text(contractmonth+"个月");
                $(".terminate_starttime").text(contractstarttime);
                $(".terminate_lasttime").text(contractlasttime);
                $(".terminate_payfee").text(payfee+"元");
                $(".terminate_withdrawal").text(withdrawal+"元");
                $(".shop_down").show();
            }else{
                public_prompt();
            }
    	}
        $("input[name='submit_terminate_shop']").click(function() {
            $('.shop_down_btn').attr({"disabled":"disabled"});
            var shopid= $("input[name='terminate_shopid']").val();
            if(shopid == '') {
                alert("请选择商家");return;
            }
            $.ajax({
                url:'/console/salesman/shop/status/update',
                type: 'post',
                data:{
                    cityid:cityid,
                    shopid:shopid,
                    status:0
                },
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        //$(".shop_down").hide();
                        location.reload();
                    } else {
                        alert(data.message);
                        $('.shop_down_btn').removeAttr("disabled");
                    }
                }
            })
        });
    	//恢复
    	function renew(shopid, shopname, address) {
            if(shopPower('shopSalesmanManagement:edit') == 1){
                $(".public_prompt_mark").show();
                $(".public_prompt_mark").height($(window).height());
                $(".renew_shopid input[name='renew_shopid']").val(shopid);
                $(".renew_shopname").text(shopname);
                $(".renew_address").text(address);
                $(".shop_renew").show();
            }else{
                public_prompt();
            }
    	}
    	$("input[name='submit_renew_shop']").click(function() {
            $(".shop_renew_btn").attr({"disabled":"disabled"});
            var shopid= $(".renew_shopid input[name='renew_shopid']").val();
            if(shopid == '') {
                alert("请选择商家");return;
            }
            var type = $("select[name='renew_type']").val();
            var payfee=$("input[name='renew_payfee']").val();
            var contractmonth = $("select[name='renew_contractmonth']").val();
            $.ajax({
                url:'/console/salesman/shop/status/update',
                type: 'post',
                data:{
                    cityid:cityid,
                    shopid:shopid,
                    status:1,
                    payfee:payfee,
                    type:type,
                    contractmonth:contractmonth
                },
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        alert(data.message);
                        //$(".shop_renew").hide();
                        location.reload();
                    } else {
                        alert(data.message);
                        $(".shop_renew_btn").removeAttr("disabled");
                    }
                }
            })
        });
    </script>
@endsection